% !TeX encoding=utf8
% !TeX spellcheck = en-US

\chapter{Coding Style}
\label{chapter:CodingStyle}

\begin{mdframed}
\lettrine{A}{} lways code as if the person who ends up maintaining your code is a violent psychopath who knows where you live.
\end{mdframed}

Of course we don't know where you live but other people might actually want to use your code. The \href{http://google-styleguide.googlecode.com/svn/trunk/cppguide.html}{Google C++ Style Guide} is a good guideline. 

\section{C++11}
\label{sec:Cpp11}

C++11 introduced a lot of useful new features. If you are not familiar with C++11 take a look \href{http://www.codeproject.com/Articles/570638/Ten-Cplusplus-Features-Every-Cplusplus-Developer}{here} and try to make use of them. Especially the new pointer types. 

\section{Documentation}
\label{sec:Documentation}

Documentation should be done in \href{http://www.stack.nl/~dimitri/doxygen/}{Doxygen}. You have to use the C++ comment blocks starting with \texttt{///}, JavaDoc and QtDoc are not activated. 

\begin{lstlisting}
///
/// \brief HashMap is a wrapper class for unordered_map with some extra features,
/// e.g. a proper contains function and a random subset of the map can be 
/// generated.
/// \details A HashMap<KEY, VALUE> maps objects from type KEY to objects from 
/// type value. It manages a unordered_map<KEY, VALUE> object and has some 
/// special features. The first one is that the [] operator does not add keys to 
/// the hash map when you try to access them although they did not exist. 
/// Additionally you can get random subsets of the elements, keys or values.
///
/// @tparam KEY type used as the key in the hash map
/// @tparam VALUE type of the mapped values
/// \author Emanuel Laude and Zorah L\"ahner
///
\end{lstlisting}

You can find a list of all possible commands \href{http://www.stack.nl/~dimitri/doxygen/manual/commands.html}{here}.

\subsection{Installing and Using Doxygen}
\label{subsec:Doxygen}

After \href{http://www.stack.nl/~dimitri/doxygen/download.html}{installing} Doxygen, you can update the documentation with the Doxyfile found in the projects root folder. If you have problems installing Doxygen with the binaries, try to compile it yourself. 

Use
\begin{lstlisting}[language=bash, numbers=none]
	doxygen Doxyfile
\end{lstlisting}
in the root folder.

\begin{mdframed}
Do not add all the files produced by Doxygen to the repository.
\end{mdframed}